package cn.bailin233.gateway.compoent.saToken;

import cn.bailin233.gateway.compoent.feign.SystemService;
import cn.dev33.satoken.stp.StpInterface;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 自定义权限验证接口扩展
 */
@Component
public class StpInterfaceImpl implements StpInterface {

    @Autowired
    SystemService systemService;

    // 返回此 loginId 拥有的权限列表
    @Override
    public List<String> getPermissionList(Object loginId, String loginType) {
        System.out.println("网关鉴定角色");
        return systemService.getRoleNameList(Long.valueOf(loginId + ""));
    }

    // 返回此 loginId 拥有的角色列表
    @Override
    public List<String> getRoleList(Object loginId, String loginType) {
        System.out.println("网关鉴定权限");
        return systemService.getResourceNameList(Long.valueOf(loginId + ""));
    }

}
